package com.uy.cuantoconocesdeuruguay.controllers;

import com.uy.cuantoconocesdeuruguay.MainActivity;
import com.uy.cuantoconocesdeuruguay.exceptions.ConnectivityException;
import com.uy.cuantoconocesdeuruguay.server.HttpsExecuter;
import com.uy.cuantoconocesdeuruguay.server.ServerInfo;

public class NotificationsController {
	private static final String SERVER_PREFIX = ServerInfo.SERVER_SECURE_HOST;

	public static void setGoogleGCMRegId(String regId) throws ConnectivityException   {
		String deviceID = MainActivity.userData.getDeviceID();		
		String completeURL = SERVER_PREFIX+ServerInfo.NOTIFICATIONS_PATH;
		String query = "deviceid="+deviceID+"&operation=setGoogleGCMRegId&regId="+regId;
		HttpsExecuter.execute(completeURL, query, true);
	}
	public static void sendChallengeNotification(String oponentFacebookId) throws ConnectivityException   {
		String deviceID = MainActivity.userData.getDeviceID();		
		String completeURL = SERVER_PREFIX+ServerInfo.NOTIFICATIONS_PATH;
		String query = "deviceid="+deviceID+"&operation=sendChallengeNotification&oponentFacebookId="+oponentFacebookId+"&myName="+MainActivity.userData.getFacebookName();
		HttpsExecuter.execute(completeURL, query, false);
	}
	public static void sendChallengeAcceptedNotification(String oponentFacebookId) throws ConnectivityException   {
		String deviceID = MainActivity.userData.getDeviceID();		
		String completeURL = SERVER_PREFIX+ServerInfo.NOTIFICATIONS_PATH;
		String query = "deviceid="+deviceID+"&operation=sendChallengeAcceptedNotification&oponentFacebookId="+oponentFacebookId+"&myName="+MainActivity.userData.getFacebookName();
		HttpsExecuter.execute(completeURL, query, false);
	}
}
